package aptech.eproject.logictics.db;

import java.io.Serializable;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Set;

/**
 * The persistent class for the CUSTOMER database table.
 * 
 */
@Entity
@Table(name = "CUSTOMER")
@NamedQueries({
    @NamedQuery(name = "findCustomerByName", query = "SELECT c FROM Customer c WHERE c.fullName LIKE ?1")})
public class Customer implements Serializable {

    private static final long serialVersionUID = 1L;
    private String userName;
    private String address;
    private Timestamp dateOfBirth;
    private String email;
    private String fullName;
    private String gender;
    private boolean isBlocked;
    private String password;
    private String phoneNumber;
    private City city;
    private Set<Delivery> deliveries;

    public Customer() {
    }

    @Id
    @Column(name = "USER_NAME", nullable = false)
    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Column(name = "ADDRESS", nullable = false)
    public String getAddress() {
        return this.address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    

    @Column(name = "DATE_OF_BIRTH", nullable = false)
    public Timestamp getDateOfBirth() {
        return this.dateOfBirth;
    }

    public void setDateOfBirth(Timestamp dateOfBirth) {
        this.dateOfBirth = dateOfBirth;
    }

    @Column(name = "EMAIL", nullable = false)
    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Column(name = "FULL_NAME", nullable = false)
    public String getFullName() {
        return this.fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    @Column(name = "GENDER", nullable = false)
    public String getGender() {
        return this.gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    @Column(name = "IS_BLOCKED", nullable = true)
    public boolean getIsBlocked() {
        return this.isBlocked;
    }

    public void setIsBlocked(boolean isBlocked) {
        this.isBlocked = isBlocked;
    }

    @Column(name = "PASSWORD", nullable = false)
    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "PHONE_NUMBER", nullable = true)
    public String getPhoneNumber() {
        return this.phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    //bi-directional many-to-one association to City
    @ManyToOne
    @JoinColumn(name = "CITY_ID", nullable = false)
    public City getCity() {
        return this.city;
    }

    public void setCity(City city) {
        this.city = city;
    }

    //bi-directional many-to-one association to Delivery
    @OneToMany(mappedBy = "consigner", fetch = FetchType.EAGER)
    public Set<Delivery> getDeliveries() {
        return this.deliveries;
    }

    public void setDeliveries(Set<Delivery> deliveries) {
        this.deliveries = deliveries;
    }

    public Delivery addDelivery(Delivery delivery) {
        getDeliveries().add(delivery);
        return delivery;
    }

    public Delivery removeDelivery(Delivery delivery) {
        getDeliveries().remove(delivery);
        delivery.setConsigner(null);
        return delivery;
    }
}
